import { createApp } from "vue";
import pinia from "./stores";
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import "element-plus/dist/index.css";
import App from "./App.vue";
import router from "./router";
import "./styles/index.scss";
import ElSvg from "./components/SvgIcon/ElSvg";
import "./permission";
import Category from "@/components/Category/index.vue";
import { useUserInfoStore } from "@/stores/userInfo";
const userInfoStore = useUserInfoStore();

const app = createApp(App);

ElSvg(app);

app.directive("has", (el, binding) => {
	// console.log(el, binding, userInfoStore.userInfo.buttons);
	//判断当前的指令的值binding.value 在不在按钮权限控制中  userInfoStore.userInfo.buttons中
	if (!userInfoStore.userInfo.buttons.includes(binding.value)) {
		//如果没有这个权限，则把当前元素el直接删除
		el.remove();
	}
});

app
	.use(pinia)
	.use(router)
	.use(ElementPlus, {
		locale: zhCn,
	})
	.component("Category", Category)
	.mount("#app");
